package com.yhl.admin.config;

import com.yhl.admin.Interceptor.LoginInterceptor;
import com.yhl.admin.Interceptor.RedisUrlCountInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自定义功能
 * 注册拦截器
 * @author yhl
 * @create 2021-06-18 21:21
 */
@Configuration
public class AnnotationConfig implements WebMvcConfigurer {

    @Autowired
    RedisUrlCountInterceptor redisUrlCountInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).
                addPathPatterns("/**").//拦截所有请求
                excludePathPatterns("/","/login", "/css/**",
                "/fonts/**", "/images/**", "/js/**", "/favicon.ico");//不拦截的请求

        registry.addInterceptor(redisUrlCountInterceptor).
                addPathPatterns("/main.html", "/sql");
    }
}
